package com.foxmail.aroundme.boring.base.view;

import android.view.View;

import com.foxmail.aroundme.boring.base.present.BasePre;
import com.foxmail.aroundme.boring.base.ui.BaseFragment;
import com.foxmail.aroundme.boring.utils.m_enum.DataLoadType;
import com.foxmail.aroundme.boring.utils.m_enum.RefreshType;

/**
 * Created by gzl on 1/22/17.
 * 基本数据Fragment
 */

public abstract class BaseDataFragment<T extends BasePre, R> extends BaseFragment<T> implements BaseDataView<R> {

    @Override
    public void updateNewsList(R data, @DataLoadType.LoadType int refreshType, String channelId, boolean isCache) {
        switch (refreshType) {
            case DataLoadType.TYPE_LOAD_DB_SUCCESS:
            case DataLoadType.TYPE_LOAD_DB_NO_DATA:

            case DataLoadType.TYPE_REFRESH_SUCCESS:
                refreshSuccess(data, refreshType, channelId, isCache);
                break;
            case DataLoadType.TYPE_REFRESH_FAIL:
                requestError(refreshType);
                break;
            case DataLoadType.TYPE_REFRESH_NO_DATA:
                noData(refreshType, isCache);
                break;
            case DataLoadType.TYPE_REFRESH_NETWORK_ERROR:
                netConnectError(refreshType);
                break;

            case DataLoadType.TYPE_LOAD_MORE_SUCCESS:
                loadMoreSuccess(data);
                break;
            case DataLoadType.TYPE_LOAD_MORE_FAIL:
                requestError(refreshType);
                break;
            case DataLoadType.TYPE_LOAD_MORE_NO_DATA:
                noData(refreshType, false);
                break;
            case DataLoadType.TYPE_LOAD_MORE_NETWORK_ERROR:
                netConnectError(refreshType);
                break;
        }
    }


}
